import { Suspense } from "react";
import loadable from "@loadable/component";

const modules = import.meta.glob("@/views/**/*/*.tsx");

export default function LazyLoad(url: string) {
  const ComponentNode = loadable(async () => {
    if (!modules[`/src/views${url}/index.tsx`]) {
      return modules[`/src/views/404/index.tsx`]();
    }
    return modules[`/src/views${url}/index.tsx`]();
  });
  return (
    <Suspense>
      <ComponentNode></ComponentNode>
    </Suspense>
  );
}
